<meta title="操作中心" />
<div class="p">
    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-warning">
                <div class="panel-heading">
                    淘宝客订单同步
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form"
                          action="/api/taobao-union/fetch-order"
                          method="get"
                          id="tbkOrderFetchForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">订单状态</label>
                            <div class="col-sm-10">
                                <select class="form-control" s="select"
                                        name="payStatus"
                                        s-build="S.get('/api/enum/valuesMap/core.enums.TkOrderPayStatus')">
                                    <option value="">全部订单</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">订单场景</label>
                            <div class="col-sm-10">
                                <select class="form-control" s="select"
                                        name="scene"
                                        s-build="S.get('/api/enum/valuesMap/core.enums.TkOrderScene')">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">查询方式</label>
                            <div class="col-sm-10">
                                <select class="form-control" s="select"
                                        name="queryType"
                                        s-build="S.get('/api/enum/valuesMap/core.enums.TkOrderQueryType')">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">开始时间</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" s="datetimepicker"
                                       autocomplete="off"
                                       s-datetimepicker="{minView:'hour', format:'yyyy-mm-dd hh:ii:ss'}" name="startTime" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">结束时间</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" s="datetimepicker"
                                       autocomplete="off"
                                       s-datetimepicker="{minView:'hour', format:'yyyy-mm-dd hh:ii:ss'}" name="endTime" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="fetchTbkOrder()" class="btn btn-default">同步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-heading">
                    淘宝客订单导入
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form,valid"
                          action="/api/taobao-union/import"
                          method="post"
                          enctype="multipart/form-data"
                          id="tbkOrderImportForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">选择淘宝订单文件</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="file" s-valid-error="require()"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="importTbkOrder()" class="btn btn-default">导入</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-heading">
                    商品清理
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form"
                          action="/api/commissionItem/clean"
                          method="put"
                          id="itemCleanForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最高优惠券金额</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="maxCouponValue"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最低价</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="startPrice"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最高价</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="endPrice"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">最高销量</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="maxSales"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-10">
                                <select class="form-control" s="select"
                                        name="status"
                                        s-build="S.get('/api/enum/valuesMap/core.enums.CommissionItemStatus')">
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="return cleanItem()" class="btn btn-default">开始清理</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-body">
                    <button type="button" s-click="return commissionOrderSettle()" class="btn btn-default">佣金订单结算</button>
                    <button type="button" s-click="return syncRegion()" class="btn btn-default">地区同步</button>
                    <button type="button" s-click="return clearIndexCache()" class="btn btn-default">清空首页缓存</button>
                    <button type="button" s-click="return rebuildIndex()" class="btn btn-default">重建商品索引</button>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="panel panel-warning">
                <div class="panel-heading">
                    优惠券导入
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form,valid"
                          action="/api/commission-item-import/import"
                          method="post"
                          enctype="multipart/form-data"
                          id="recommendImportForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">优惠券文件</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="file" s-valid-error="require()"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">来源</label>
                            <div class="col-sm-10">
                                <select class="form-control input-sm" s="select" name="sourceFrom">
                                    <option value="TBK_RECOMMEND_COUPON">淘宝联盟每日精选优惠券</option>
                                    <option value="JHS_99">聚划算99大促预售爆款</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">频道</label>
                            <div class="col-sm-10">
                                <select class="form-control input-sm" s="select" s-build="S.get('/api/channel/list')" name="channelId">
                                    <option value="">不选频道</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">2003XLS</label>
                            <div class="col-sm-10">
                                <label class="s-checkbox">
                                    <input autocomplete="off" name="xls" checked type="checkbox">
                                    <span class="s-checkbox-indicator"></span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">仅优惠券</label>
                            <div class="col-sm-10">
                                <label class="s-checkbox">
                                    <input autocomplete="off" name="onlyCoupon" type="checkbox">
                                    <span class="s-checkbox-indicator"></span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">设为推荐</label>
                            <div class="col-sm-10">
                                <label class="s-checkbox">
                                    <input autocomplete="off" name="recommend" type="checkbox">
                                    <span class="s-checkbox-indicator"></span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="return importRecommendCoupon()" class="btn btn-default">导入</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-heading">
                    淘宝类目同步
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form"
                          action="/api/taobao-item-cat/sync"
                          method="get"
                          id="taobaoItemCatForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">父类目ID</label>
                            <div class="col-sm-10">
                                <input autocomplete="off" type="text" class="form-control" value="0" name="parentCid" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="syncTaobaoItemCat().done(function() {S.notice('同步成功')})" class="btn btn-default">同步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-heading">
                    京东联盟订单同步
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form"
                          action="/api/jd-union/fetch-order"
                          method="get"
                          id="jdUnionFetchForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">时间</label>
                            <div class="col-sm-10">
                                <input autocomplete="off" type="text" class="form-control" autocomplete="off" s="datetimepicker"
                                       s-datetimepicker="{format:'yyyymmdd'}" name="time" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="fetchJdUnionOrder()" class="btn btn-default">同步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="panel panel-warning">
                <div class="panel-heading">
                    多多客订单同步
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" s="form,valid"
                          action="/api/ddk/fetch-order"
                          method="get"
                          id="ddkOrderFetchForm">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">开始时间</label>
                            <div class="col-sm-10">
                                <input autocomplete="off" type="text" class="form-control" s-valid-error="require()" value="" s="datetimepicker" name="startUpdateTime" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">结束时间</label>
                            <div class="col-sm-10">
                                <input autocomplete="off" type="text" class="form-control" s-valid-error="require()" s-datetimepicker="{pickerPosition:'top-left'}"
                                       s="datetimepicker" name="endUpdateTime" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">PID</label>
                            <div class="col-sm-10">
                                <input autocomplete="off" type="text" class="form-control" name="pid" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" s-click="return $ddkOrderFetchForm.submit().done(function() {S.notice('同步成功')})" class="btn btn-default">同步</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function fetchTbkOrder() {
        return $tbkOrderFetchForm.submit().done(function() {
            S.notice("同步成功")
        })
    }
    function syncTaobaoItemCat() {
        return $taobaoItemCatForm.submit()
    }

    function commissionOrderSettle() {
        return S.post("/api/commission-order/settle").done(function() {
            S.toast("佣金订单结算完成");
        })
    }

    function taobaoUnionLogin() {
        return S.get("/api/taobao-union/login").done(function(flag) {
            if(flag) {
                S.toast("淘宝联盟登录测试成功");
            } else {
                S.toast("淘宝联盟登录测试失败");
            }
        })
    }

    function syncRegion() {
        return S.get("/api/region/sync").done(function() {
            S.toast("地区同步完成");
        })
    }

    function fetchJdUnionOrder() {
        return $jdUnionFetchForm.submit().done(function() {
            S.notice("同步成功")
        })
    }
    function importTbkOrder() {
        $tbkOrderImportForm.submit().done(function() {
            S.toast("导入成功", "success")
        })
    }
    function importRecommendCoupon() {
        return $recommendImportForm.submit().done(function() {
            S.toast("文件上传成功，请等待商品更新中，可能需要5分钟左右时间", "success")
        })
    }

    function clearIndexCache() {
        return S.get("/api/cache/clear/INDEX_PAGE")
    }

    function rebuildIndex() {
        return S.post("/api/commissionItem/rePushDocument")
    }

    function cleanItem() {
        return $itemCleanForm.submit()
    }
</script>